package cn.training.service;

import java.util.List;

import jp.terasoluna.fw.dao.QueryDAO;
import jp.terasoluna.fw.dao.UpdateDAO;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.training.bean.UserBean;
@Service
public class HelloWorldService {
//	public UserBean searchUser(UserBean frm){
//		frm.setUserId("text");
//		return frm;	
//	}
	@Autowired
	QueryDAO queryDao;
	
	@Autowired
	UpdateDAO updateDao;
	public UserBean searchUser(UserBean frm) {
		UserBean userBean = new UserBean();
		userBean.setUserId(frm.getUserId());
		userBean.setPassword(frm.getPassword());
		UserBean result = queryDao.executeForObject("User.searchUser",frm,UserBean.class);
		return result;
	}
	public List<UserBean> searchAll(UserBean frm) {
		List<UserBean> result = queryDao.executeForObjectList("User.searchAll",frm);
		return result;
	}
	public List<UserBean> listsearchUser(UserBean lfrm) {
		List<UserBean> result = queryDao.executeForObjectList("User.listselectUser",lfrm);
		return result;
	}
	public int insertUser(UserBean cr) {
		return updateDao.execute("User.insertUser",cr);
		 
	}
	
	public UserBean supdateUser(UserBean sup) {
		UserBean result = queryDao.executeForObject("User.supdateUser",sup,UserBean.class);
		return result;
	}
	
	public int updateUser(UserBean up) {
		return updateDao.execute("User.updateUser",up);
		 
	}
	
	public int deleteUser(UserBean det) {
		return updateDao.execute("User.deleteUser",det);
		
		// TODO Auto-generated method stub
	}
	
	public UserBean okdeleteUser(UserBean okdel) {
		UserBean result = queryDao.executeForObject("User.okdeleteUser",okdel,UserBean.class);
		return result;
	}
	
	public UserBean searchUserl(UserBean lg) {
		UserBean result = queryDao.executeForObject("User.searchUser",lg,UserBean.class);
		return result;
	}
	
	public int registerUser(UserBean reg) {
		return updateDao.execute("User.insertUser",reg);
		 
	}
	
	public UserBean update1User(UserBean up1) {
		UserBean result = queryDao.executeForObject("User.update1User",up1,UserBean.class);
		return result;
	}
	
	public int userupdateUser(UserBean up) {
		return updateDao.execute("User.userupdateUser",up);
		 
	}
	
}
